package taks5;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Account {
	
	final Lock lock = new ReentrantLock();
	final Condition isUsed = lock.newCondition();
	
	final Bank bank;
	
	int money;
	
	public Account(Bank bank, int money){
		this.bank = bank;
		this.money = money;
	}
	
	int withdraw(int amount){
		int toWithdraw = amount <= money ? amount : money;
		money -= toWithdraw;
		return toWithdraw;
	}
	
	int deposit(int amount){
		money += amount;
		return amount;
	}
}
